class Solution {
public:
    vector<int> maxSubsequence(vector<int>& nums, int k) {
        
        vector<int> ret;
        vector<pair<int,int>> cy;
        vector<int> idx;
        for(int i=0;i<nums.size();++i){

            cy.push_back({nums[i],i});
        }
        sort(cy.begin(),cy.end(),[](pair<int,int> &p1,pair<int,int> &p2){

            return p1.first>p2.first;
        });
        for(int i=k-1;i>=0;--i){

            idx.push_back(cy[i].second);
        }
        sort(idx.begin(),idx.end());
        for(int i=0;i<idx.size();++i){

            ret.push_back(nums[idx[i]]);
        }
        return ret;
    }
};
